'use strict';
module.exports = {
	/**
	 * 统计粉丝
	 * @url client/user/kh/getFansStats 前端调用的url参数地址
	 * data 请求参数
	 * @param {String} params1  参数1
	 */
	main: async (event) => {
		let { data = {}, userInfo, util, filterResponse, originalParam } = event;
		let { customUtil, uniID, config, pubFun, vk, db, _ } = util;
		let { uid } = data;
		let res = { code: 0, msg: "" };
		// 业务逻辑开始-----------------------------------------------------------
		let dbName = "db-fans";
		
		let { yesterdayStart, yesterdayEnd } = vk.pubfn.getCommonTime(new Date());
		
		let fans_num = await vk.baseDao.count({
			dbName,
			whereJson: {
				uid: userInfo._id,
				_add_time: _.gte(yesterdayStart).lte(yesterdayEnd)
			}
		})
		
		let fans_sum = await vk.baseDao.count({
			dbName,
			whereJson: {
				uid: userInfo._id
			}
		})
		
		res["data"] = {
			fans_num,
			fans_sum
		}
		// 业务逻辑结束-----------------------------------------------------------
		return res;
	}
}
